/// @description 更新相机
// You can write your code in this editor
//更新目标方向
if(instance_exists(follow))
{
	xTo = follow.x;
	yTo = follow.y;
}

//更新位置
x += (xTo - x) / 15;
y += (yTo - y) / 15;

//保持相机在房间中心
x = clamp(x, viewWidthHalf, room_width - viewWidthHalf);
y = clamp(y, viewHeightHalf, room_height - viewHeightHalf);

//窗口抖动
x += random_range(-shakeRemain,shakeRemain);
y += random_range(-shakeRemain,shakeRemain);

shakeRemain = max(0,shakeRemain - ((1/shakeLength)*shakeMagnitude));

//相机真实位置
camera_set_view_pos(cam,x - viewWidthHalf,y - viewHeightHalf);